package com.china08.yxyapi.repository.db;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.china08.yxyapi.entity.db.lessons.YxyLessonsSchoolCatalog;

public interface YxyLessonsSchoolCatalogRepository extends JpaRepository<YxyLessonsSchoolCatalog, String> {

    List<YxyLessonsSchoolCatalog> findByPidAndSchoolIdOrderByOrderNumAsc(String pid, String schoolId);

    YxyLessonsSchoolCatalog findById(String id);

    List<YxyLessonsSchoolCatalog> findBySchoolIdAndLevelOrderByOrderNum(String schoolId, Integer level);

    List<YxyLessonsSchoolCatalog> findBySchoolIdAndPidAndLevelOrderByOrderNum(String schoolId, String pid,
            Integer level);

    Integer countByLevel(int i);

    List<YxyLessonsSchoolCatalog> findByPid(String idOne);

    Integer countByPidAndLevelAndSchoolId(String pid, Integer level, String schoolIdOne);

    YxyLessonsSchoolCatalog findByNameAndLevelAndSchoolId(String nameTwo, Integer level, String schoolIdOne);

    Integer countByLevelAndSchoolId(int i, String schoolIdOne);

    YxyLessonsSchoolCatalog findByIdAndPidAndSchoolId(String idTwo, String idOne, String schoolIdTwo);

    @Query(value = " SELECT * FROM yxy_lessons.yxy_lessons_school_catalog WHERE school_id = ?1 AND LEVEL = ?2  ORDER BY order_num ASC, last_modified_date DESC ", nativeQuery = true)
    List<YxyLessonsSchoolCatalog> findBySchoolIdAndLevelAll(String schoolId, int i);

    @Query(value = " SELECT * FROM yxy_lessons.yxy_lessons_school_catalog WHERE school_id = ?1 AND LEVEL = ?2 AND pid = ?3  ORDER BY order_num ASC, last_modified_date DESC ", nativeQuery = true)
    List<YxyLessonsSchoolCatalog> findBySchoolIdAndLevelAndPidAll(String schoolId, int i, String id1);

    List<YxyLessonsSchoolCatalog> findByPidAndLevel(String id, int i);

    List<YxyLessonsSchoolCatalog> findBySchoolIdAndLevel(String schoolId, int i);

    List<YxyLessonsSchoolCatalog> findByLevel(int i);

    @Query(value = "select t from YxyLessonsSchoolCatalog t where t.level = ?1 and t.pid = ?2")
    List<YxyLessonsSchoolCatalog> findByLevelAndPid(int i, String pid);

    List<YxyLessonsSchoolCatalog> findBySchoolIdAndPidAndLevel(String schoolIdOne, String oneId, int i);

    YxyLessonsSchoolCatalog findByNameAndLevelAndPid(String nameTwo, Integer level, String pid);

    YxyLessonsSchoolCatalog findByNameAndLevelAndSchoolIdAndPid(String nameTwo, int i, String schoolIdTwo,
            String idOne);

}
